  // CheckersBoard Engine API - Native Code Layer
 // CB Threading header file
////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "API.h"

// synchronization events
#define CB_EVENT_COMPUTEMOVE				0
#define CB_EVENT_TERMINATE					1
#define CB_EVENT_MOVECOMPUTED				2
#define CB_EVENT_THREAD_EXITED				3
#define CB_EVENT_COUNT						4

// define subsets of events for waiting
#define CB_ENGINE_INDEX						0
#define CB_ENGINE_EVENT_COUNT				2
#define CB_CLI_EVENT_INDEX					2
#define CB_CLI_EVENT_COUNT					2

// synchronization struct
struct CBSynch
{
	HANDLE hEvents[CB_EVENT_COUNT];
};

// the global thread parameter container struct
struct CBThreadParams
{
	// internal parameters
	CBSynch* pSynch;
	CB_APIStruct* pAPI;

	// Event Handle for move computed
	HANDLE* phMoveComputed;

	// compute-move parameters
	int* pBoard;
	int color;
	double maxtime;
	CBmove* move;
};

 // Functions
/////////////////////////////////////////////

// init/close events
void InitEvents(CBSynch *pS);
void CloseEvents(CBSynch *pS);

// CB engine thread
DWORD WINAPI CBEngineThread(LPVOID lpThreadParameter);

